import java.util.Scanner;

public class QuadraticEquation{
    private double a;
    private double b;
    private double c;
    QuadraticEquation(){

    }
    QuadraticEquation(double a,double b,double c){
        this.a=a;
        this.b=b;
        this.c=c;
    }
    public double getA(){
        return a;
    }
    public double getB(){
        return b;
    }
    public double getC(){
        return c;
    }

    public double getDiscriminant(){
        return b*b-4*a*c;
    }
    public double getroot1(){
        if(getDiscriminant()>0){
            return (-b+Math.sqrt(getDiscriminant()))/(2*a);
        }
        else
            return 0;
    }
    public double getroot2(){
        if(getDiscriminant()>0){
            return (-b-Math.sqrt(getDiscriminant()))/(2*a);
        }
        else
            return 0;
    }
    public static void main(String[] args){
        Scanner input =new Scanner(System.in);
        System.out.println("请输入a的值：");
        double a=input.nextDouble();
        System.out.println("请输入b的值：");
        double b=input.nextDouble();
        System.out.println("请输入c的值：");
        double c=input.nextDouble();
        QuadraticEquation equation =new QuadraticEquation(a,b,c);
        double discriminant=equation.getDiscriminant();
        if(discriminant>0){
            //两个实根
            double r1=equation.getroot1();
            double r2=equation.getroot2();
            System.out.println("方程有两个根"+ r1 + "and"+r2);
        }
        else if(discriminant==0){
            //一个实根
            double root=equation.getroot1();
            System.out.println("方程有一个根"+root);
        }
        else{
            //无根
            System.out.println("方程无根");
        }
    }
}

